package com.huoniu.order.service.impl;

import com.huoniu.order.entity.User;
import com.huoniu.order.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;

/**
 * @类 名： UserServiceImpl <br/>
 * @描 述： <br/>
 * @日 期： 2020/9/17 9:53<br/>
 * @作 者： 侯建军<br/>
 * @版 本： 1.0.0
 * @since JDK 1.8
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    private RestTemplate restTemplate;


    @Override
    public String getUsername() {
//        String str = restTemplate.getForObject("http://localhost:8001/user/getUserName?username=admin", String.class);
        String str = restTemplate.getForObject("http://USER-SERVICE/user/getUserName?username=admin", String.class);
       log.info(str);
        return str;
    }
    @Override
    public User getUserData(String username){
        ResponseEntity<User> user=restTemplate.getForEntity("http://USER-SERVICE/user/getUserData?username="+username,User.class);
        return user.getBody();
    }
}
